﻿using System;
using System.Collections.Generic;

namespace Web7.Ioc
{
    /// <summary>
    /// 依赖解析的接口。具体的实现时,允许选择一个IoC容器类型。
    /// </summary>
    public interface IWeb7DependencyResolver
    {
        /// <summary>获取依赖服务</summary>
        /// <typeparam name="T">注册服务时的类型</typeparam>
        /// <returns>该类型的实例<typeparamref name="T"/>.</returns>
        T Resolve<T>();

        /// <summary>
        /// 获取所有的依赖服务
        /// </summary>
        /// <typeparam name="T">注册服务时的类型</typeparam>
        /// <returns> An <see cref="IEnumerable{T}"/> 该类型的实例 <typeparamref name="T"/>.</returns>
        IEnumerable<T> ResolveAll<T>();

        /// <summary>根据所需的名称获取依赖服务</summary>
        /// <typeparam name="T">注册服务时的类型</typeparam>
        /// <param name="name">该服务的名称</param>
        /// <returns>.</returns>
        T Resolve<T>(string name);

        /// <summary>获取依赖服务</summary>
        /// <param name="type">注册服务时的类型</param>
        /// <returns>该类型的实例<paramref name="type"/>.</returns>
        object Resolve(Type type);

        /// <summary>
        /// 获取所有的依赖服务
        /// </summary>
        /// <param name="type">注册服务时的类型</param>
        /// <returns>
        /// An <see cref="IEnumerable{T}"/>该类型的实例<paramref name="type"/>.
        /// </returns>
        IEnumerable<object> ResolveAll(Type type);

        /// <summary>获取所有的依赖服务</summary>
        /// <param name="type">注册服务时的类型</param>
        /// <param name="name">该服务的名称</param>
        /// <returns>该类型的实例<paramref name="type"/>.</returns>
        object Resolve(Type type, string name);
    }
}
